FROM centos:7.9.2009
MAINTAINER Peter Tam "1518981153@qq.com"

ENV TZ=Asia/Shanghai
ENV LANG=en_US.UTF-8

COPY CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
COPY epel-7.repo /etc/yum.repos.d/epel-7.repo

RUN yum -y update && yum install -y wget vim curl ping net-tools supervisor nginx \
	&& yum install -y epel-release https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm \
	&& rpm -i https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm --nodeps \
	&& groupadd www \
    && useradd -g www -s /sbin/nologin www
	
RUN yum -y install php php-opcache php-cli php-devel php-pdo php-pgsql php-sqlite3 php-gd php-curl php-memcached php-imap php-mysqlnd php-mysql php-mbstring php-xml php-zip php-bcmath php-soap php-intl php-readline php-pcov php-msgpack php-igbinary php-ldap php-redis php-pear php-dom php-mcrypt php-odbc php-mssql php-mysqli php-pecl-swoole php-pecl-yaf php-pecl-redis php-fpm --enablerepo=remi-php80

RUN echo y | pecl install Phalcon && yum clean all

RUN wget https://getcomposer.org/download/2.0.12/composer.phar -O /usr/local/bin/composer && chmod +x /usr/local/bin/composer && composer config -g repo.packagist composer https://packagist.phpcomposer.com

RUN mkdir -p /data/supervisor/tmp /data/supervisor/conf.d /data/supervisor/logs /data/nginx/conf.d /data/nginx/log /data/php-fpm/logs /data/www
RUN sed -i 's/listen = 127.0.0.1:9000/listen = 9000/g' /etc/php-fpm.d/www.conf && sed -i 's/listen.allowed_clients = 127.0.0.1/;listen.allowed_clients = 0.0.0.0/g' /etc/php-fpm.d/www.conf
RUN echo "[swoole]" >> /etc/php.ini \
	&& echo "extension = json" >> /etc/php.ini \
	&& echo "extension = pdo.so" >> /etc/php.ini \
	&& echo "extension = psr.so" >> /etc/php.ini \
	&& echo "extension = phalcon.so" >> /etc/php.ini \
	&& echo "cgi.fix_pathinfo = 0"

COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY supervisord.conf /etc/supervisord.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY php-fpm.conf /etc/php-fpm.conf
COPY nginx-php.conf /data/supervisor/conf.d/nginx-php.conf
COPY site.conf /data/nginx/conf.d/site.conf
COPY index.php /data/www/index.php

VOLUME /data/www

EXPOSE 80

ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]